/**
 * Package	: com.vasms.common.Exception
 * File		: BusinessException.java
 * Company 	: Shenzhen Coship Electronics CO., LTD.
 * Version  : v1.0
 * Description 	: <Detail Description for package>
 *
 * Copyright (c) 2003-2009 Shenzhen Coship Electronics CO., LTD.
 * Rainbow Bldg.,North,Hi-Tech Industrial Park,Nanshan District,Shenzhen,China,P.C.518057.
 * All rights reserved.
 * The contents of this file are confidential and proprietary to COSHIP.
 * Copying is explicitly prohibited without the express permission of COSHIP.
 *
 * Create Date	: Nov 2, 2009
 * Create By    : 903329
 * History :$
 */
package com.coship.vasms.adstorm.exception;

/**
 * 
 * File Name : BusinessException.java
 * 
 * @Description : 业务层异常封闭类,支持到error_massage.xml配置文件中取配置信息
 * @author 903329
 */
public class BusinessException extends Exception {

	/**
	 * 默认错误代码
	 */
	public static final String DEFAULT_ERROR_CODE = "default_error";

	/**
	 * 
	 * Description : <Detail Description for method>
	 * 
	 * @return
	 * 
	 */
	public String getErrorText() {
		if (errorCode == null || errorCode.trim().length() == 0) {
			return null;
		}
		return ExceptionConfigCache.getInstance().getErrorText(errorCode);
	}

	/**
	 * 错误返回代码
	 */
	private String errorCode;

	public BusinessException(String errorCode, String message, Throwable cause) {
		super(message, cause);
		this.errorCode = errorCode;
	}

	public BusinessException(String message, Throwable cause) {
		super(message, cause);
	}

	public BusinessException(Throwable cause) {
		super(cause);
		if (cause instanceof BusinessException) {
			BusinessException e = (BusinessException) cause;
			this.errorCode = e.errorCode;
		}
	}

	public BusinessException(String errorCode) {
		super();
		this.errorCode = errorCode;
	}

	public BusinessException(String errorCode, String message) {
		super(message);
		this.errorCode = errorCode;
	}

	/**
	 * @return the errorCode
	 */
	public String getErrorCode() {
		return errorCode;
	}

	/**
	 * @param errorCode
	 *            the errorCode to set
	 */
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

}
